/*     */ import java.awt.Color;
/*     */ import java.awt.Container;
/*     */ import java.awt.Dimension;
/*     */ import java.awt.Font;
/*     */ import java.awt.Graphics;
/*     */ import java.awt.Graphics2D;
/*     */ import java.awt.Insets;
/*     */ import java.awt.event.ActionEvent;
/*     */ import java.awt.event.ActionListener;
/*     */ import java.awt.event.MouseEvent;
/*     */ import java.awt.event.MouseMotionListener;
import java.awt.geom.Line2D;
/*     */ import java.awt.geom.Line2D.Double;
/*     */ import java.text.DecimalFormat;
/*     */ import java.util.Arrays;
/*     */ import java.util.List;
/*     */ import javax.swing.BorderFactory;
/*     */ import javax.swing.Box;
/*     */ import javax.swing.BoxLayout;
/*     */ import javax.swing.JButton;
/*     */ import javax.swing.JDialog;
/*     */ import javax.swing.JFrame;
/*     */ import javax.swing.JLabel;
/*     */ import javax.swing.JOptionPane;
/*     */ import javax.swing.JPanel;
/*     */ import javax.swing.JTextField;
import javax.swing.border.TitledBorder;
/*     */ 
/*     */ public class OBVChart extends JPanel
/*     */   implements MouseMotionListener, BBIInterface, ActionListener
/*     */ {
/*     */   private SymQuotes sq;
/*     */   private String sym;
/*  14 */   private float yScale = 1.0F;
/*  15 */   private float xScale = 1.0F;
/*     */   private double stickWidth;
/*     */   private float minVal;
/*     */   private float maxVal;
/*     */   private int parm1;
/*     */   private float[] obv;
/*     */   private float[] obvMA_parm1;
/*  21 */   private String m = "";
/*     */   private int mX;
/*     */   private int mY;
/*  23 */   public int noOfDays = 150;
/*     */   private double p1Y;
/*     */   private double p2Y;
/*     */   private double p11Y;
/*     */   private double p22Y;
/*     */   private JTextField parm1TF;
/*     */   private JButton chgParmOk;
/*     */   private JButton chgParmCancel;
/*     */   private JButton defaultParms;
/*     */   private JDialog chgParmDialog;
/*  31 */   private DecimalFormat df = new DecimalFormat("0.00E00");
/*     */ 
/*  33 */   public String trend = "";
/*     */   public OBVChart.EastPanel ep;
/*     */   private double refY;
/*     */   private double refX;
/* 507 */   private Font ssp10 = new Font("SansSerif", 0, 10);
/* 508 */   private Font ssp9 = new Font("SansSerif", 0, 9);
/* 509 */   private Line2D.Double refL1 = new Line2D.Double();
/* 510 */   private Line2D.Double refL2 = new Line2D.Double();
/* 511 */   private Line2D.Double gridY = new Line2D.Double();
/* 512 */   private Line2D.Double gridX = new Line2D.Double();
/* 513 */   private Line2D.Double yrefL1 = new Line2D.Double();
/* 514 */   private Line2D.Double yrefL2 = new Line2D.Double();
/*     */   private double yfactor;
/*     */   private double startPointX;
/*     */   private int dateRef;
/*     */   private int daysRef;
/* 519 */   private Line2D.Double l1 = new Line2D.Double();
/* 520 */   private Line2D.Double l2 = new Line2D.Double();
/*     */   private double x1;
/*     */   private double y1;
/*     */   private double x2;
/*     */   private double y2;
/*     */   private double u1;
/*     */   private double v1;
/*     */   private double u2;
/*     */   private double v2;
/*     */   private double a1;
/*     */   private double b1;
/*     */   private double a2;
/*     */   private double b2;
/*     */   private double xi;
/*     */   private double yi;
/* 522 */   private Line2D.Double uA = new Line2D.Double();
/* 523 */   private Line2D.Double lA = new Line2D.Double();
/* 524 */   private Line2D.Double hA = new Line2D.Double();
/*     */ 
/*     */   public OBVChart(SymQuotes paramSymQuotes, int paramInt)
/*     */   {
/*  38 */     this.sq = paramSymQuotes;
/*  39 */     this.sym = paramSymQuotes.sym;
/*     */ 
/*  41 */     this.obv = new float[paramSymQuotes.count];
/*  42 */     this.obvMA_parm1 = new float[paramSymQuotes.count];
/*     */ 
/*  44 */     this.parm1 = paramInt;
/*     */ 
/*  46 */     if (this.noOfDays == 150)
/*  47 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else {
/*  49 */       this.stickWidth = (1.5D * this.xScale);
/*     */     }
/*  51 */     setBackground(Color.black);
/*  52 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */ 
/*  54 */     obvFinder();
/*     */ 
/*  56 */     if (paramInt < paramSymQuotes.count) {
/*  57 */       obvMA_parm1Finder();
/*     */     }
/*  59 */     findMinMax();
/*  60 */     addMouseMotionListener(this);
/*     */ 
/*  62 */     if (this.obv[(paramSymQuotes.count - 1)] >= this.obvMA_parm1[(paramSymQuotes.count - 1)])
/*  63 */       this.trend = "Bullish";
/*     */     else {
/*  65 */       this.trend = "Bearish";
/*     */     }
/*  67 */     this.ep = new OBVChart.EastPanel();
/*     */   }
/*     */ 
/*     */   public int getBBIdata(int paramInt)
/*     */   {
/*  74 */     if (this.obv[paramInt] >= this.obvMA_parm1[paramInt]) {
/*  75 */       return 1;
/*     */     }
/*  77 */     return 0;
/*     */   }
/*     */ 
/*     */   public void changeNoOfDays(int paramInt)
/*     */   {
/*  84 */     this.noOfDays = paramInt;
/*     */ 
/*  86 */     if (paramInt == 150)
/*  87 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/*  89 */       this.stickWidth = (1.5D * this.xScale);
/*  90 */     findMinMax();
/*     */   }
/*     */ 
/*     */   public void redrawChart(SymQuotes paramSymQuotes)
/*     */   {
/*  97 */     this.sq = paramSymQuotes;
/*  98 */     this.sym = paramSymQuotes.sym;
/*     */ 
/* 100 */     this.obv = new float[paramSymQuotes.count];
/* 101 */     this.obvMA_parm1 = new float[paramSymQuotes.count];
/*     */ 
/* 103 */     if (this.noOfDays == 150)
/* 104 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else {
/* 106 */       this.stickWidth = (1.5D * this.xScale);
/*     */     }
/* 108 */     obvFinder();
/*     */ 
/* 110 */     if (this.parm1 < paramSymQuotes.count) {
/* 111 */       obvMA_parm1Finder();
/*     */     }
/* 113 */     findMinMax();
/*     */ 
/* 115 */     if (this.obv[(paramSymQuotes.count - 1)] >= this.obvMA_parm1[(paramSymQuotes.count - 1)])
/* 116 */       this.trend = "Bullish";
/*     */     else {
/* 118 */       this.trend = "Bearish";
/*     */     }
/* 120 */     repaint();
/* 121 */     this.ep.updateValues();
/*     */   }
/*     */ 
/*     */   public void redrawChart()
/*     */   {
/* 128 */     Arrays.fill(this.obv, 0.0F);
/* 129 */     Arrays.fill(this.obvMA_parm1, 0.0F);
/*     */ 
/* 131 */     obvFinder();
/*     */ 
/* 133 */     if (this.parm1 < this.sq.count) {
/* 134 */       obvMA_parm1Finder();
/*     */     }
/* 136 */     findMinMax();
/*     */ 
/* 138 */     if (this.obv[(this.sq.count - 1)] >= this.obvMA_parm1[(this.sq.count - 1)])
/* 139 */       this.trend = "Bullish";
/*     */     else {
/* 141 */       this.trend = "Bearish";
/*     */     }
/* 143 */     repaint();
/* 144 */     this.ep.updateValues();
/*     */   }
/*     */ 
/*     */   public void mouseMoved(MouseEvent paramMouseEvent)
/*     */   {
/* 152 */     int j = 1;
/* 153 */     if ((paramMouseEvent.getX() >= 50) && (paramMouseEvent.getX() <= 750.0F * this.xScale + 50.0F) && (paramMouseEvent.getY() >= 10) && (paramMouseEvent.getY() <= this.yScale * 100.0F + 10.0F))
/*     */     {
/* 155 */       int i = (int)((750.0F * this.xScale - (paramMouseEvent.getX() - 50) - this.stickWidth / 2.0D) / (this.stickWidth + 1.0F * this.xScale));
/*     */ 
/* 157 */       if (this.sq.count - 1 >= i)
/*     */       {
/* 159 */         j = this.sq.count - 1 - i;
/* 160 */         this.m = ("( " + (String)this.sq.date.get(j) + ", OBV:" + this.df.format(this.obv[j]) + "  OBV MA[" + this.parm1 + "]:" + this.df.format(this.obvMA_parm1[j]) + " )");
/*     */ 
/* 162 */         this.mX = paramMouseEvent.getX();
/* 163 */         this.mY = paramMouseEvent.getY();
/* 164 */         repaint();
/* 165 */         return;
/*     */       }
/*     */ 
/* 169 */       this.m = "";
/*     */ 
/* 171 */       repaint();
/* 172 */       return;
/*     */     }
/*     */ 
/* 176 */     this.m = "";
/* 177 */     repaint();
/*     */   }
/*     */ 
/*     */   public void mouseDragged(MouseEvent paramMouseEvent)
/*     */   {
/*     */   }
/*     */ 
/*     */   private void drawValues(Graphics2D paramGraphics2D)
/*     */   {
/* 190 */     paramGraphics2D.setPaint(Color.cyan);
/*     */ 
/* 192 */     if (this.mX + this.m.length() * 5 > 750.0F * this.xScale + 50.0F) {
/* 193 */       this.mX -= this.m.length() * 5;
/*     */     }
/* 195 */     paramGraphics2D.drawString(this.m, this.mX, this.mY);
/*     */   }
/*     */ 
/*     */   private void obvFinder()
/*     */   {
/* 202 */     this.obv[0] = ((Integer)this.sq.qty.get(0)).intValue();
/*     */ 
/* 204 */     for (int i = 1; i < this.sq.count; i++)
/*     */     {
/* 206 */       if (((Float)this.sq.close.get(i)).floatValue() > ((Float)this.sq.close.get(i - 1)).floatValue()) {
/* 207 */         this.obv[i] = (this.obv[(i - 1)] + ((Integer)this.sq.qty.get(i)).intValue());
/*     */       }
/* 209 */       if (((Float)this.sq.close.get(i)).floatValue() < ((Float)this.sq.close.get(i - 1)).floatValue()) {
/* 210 */         this.obv[i] = (this.obv[(i - 1)] - ((Integer)this.sq.qty.get(i)).intValue());
/*     */       }
/* 212 */       if (((Float)this.sq.close.get(i)).floatValue() == ((Float)this.sq.close.get(i - 1)).floatValue())
/* 213 */         this.obv[i] = this.obv[(i - 1)];
/*     */     }
/*     */   }
/*     */ 
/*     */   private void obvMA_parm1Finder()
/*     */   {
/* 222 */     for (int i = 0; i < this.parm1; i++) {
/* 223 */       this.obvMA_parm1[i] = 0.0F;
/*     */     }
/* 225 */     for (int i = this.parm1; i < this.sq.count; i++)
/*     */     {
/* 227 */       float f = 0.0F;
/* 228 */       for (int j = i; j > i - this.parm1; j--)
/*     */       {
/* 230 */         f += this.obv[j];
/*     */       }
/*     */ 
/* 233 */       this.obvMA_parm1[i] = (f / this.parm1);
/*     */     }
/*     */   }
/*     */ 
/*     */   private void findMinMax()
/*     */   {
/* 242 */     int i = 1;
/* 243 */     this.minVal = this.obv[(this.sq.count - 1)];
/* 244 */     this.maxVal = this.obv[(this.sq.count - 1)];
/*     */ 
/* 246 */     for (int j = this.sq.count - 1; j >= 1; j--)
/*     */     {
/* 248 */       if (i > this.noOfDays) {
/*     */         break;
/*     */       }
/* 251 */       if (this.minVal > this.obv[j]) {
/* 252 */         this.minVal = this.obv[j];
/*     */       }
/* 254 */       if (this.maxVal < this.obv[j]) {
/* 255 */         this.maxVal = this.obv[j];
/*     */       }
/* 257 */       i += 1;
/*     */     }
/*     */ 
/* 261 */     i = 1;
/* 262 */     for (int j = this.sq.count - 1; j >= this.parm1; j--)
/*     */     {
/* 264 */       if (i > this.noOfDays) {
/*     */         break;
/*     */       }
/* 267 */       if (this.minVal > this.obvMA_parm1[j]) {
/* 268 */         this.minVal = this.obvMA_parm1[j];
/*     */       }
/* 270 */       if (this.maxVal < this.obvMA_parm1[j]) {
/* 271 */         this.maxVal = this.obvMA_parm1[j];
/*     */       }
/* 273 */       i += 1;
/*     */     }
/*     */   }
/*     */ 
/*     */   public void updateParms(int paramInt)
/*     */   {
/* 283 */     this.parm1 = paramInt;
/*     */ 
/* 285 */     obvFinder();
/* 286 */     obvMA_parm1Finder();
/* 287 */     findMinMax();
/*     */   }
/*     */ 
/*     */   public Box getOBVBox(boolean paramBoolean)
/*     */   {
/* 294 */     Box localBox = Box.createHorizontalBox();
/* 295 */     TitledBorder localTitledBorder = BorderFactory.createTitledBorder("OBV");
/*     */ 
/* 297 */     this.parm1TF = new JTextField("" + this.parm1, 2);
/* 298 */     this.parm1TF.setFont(this.ssp10);
/* 299 */     this.parm1TF.setMaximumSize(new Dimension(25, 20));
/*     */ 
/* 301 */     JLabel localJLabel1 = new JLabel("OBV MA[");
/* 302 */     JLabel localJLabel2 = new JLabel("]     ");
/*     */ 
/* 304 */     localJLabel1.setFont(this.ssp10);
/* 305 */     localJLabel2.setFont(this.ssp10);
/*     */ 
/* 307 */     localBox.add(localJLabel1);
/* 308 */     localBox.add(this.parm1TF);
/* 309 */     localBox.add(localJLabel2);
/*     */ 
/* 311 */     localBox.add(Box.createHorizontalGlue());
/*     */ 
/* 313 */     if (paramBoolean) {
/* 314 */       localBox.setBorder(localTitledBorder);
/*     */     }
/* 316 */     return localBox;
/*     */   }
/*     */ 
/*     */   public void showChgParmDialog()
/*     */   {
/* 323 */     JFrame localJFrame = new JFrame();
/* 324 */     this.chgParmDialog = new JDialog(localJFrame, "Change OBV Parameters", true);
/* 325 */     Box localBox1 = Box.createVerticalBox();
/* 326 */     Box localBox2 = Box.createHorizontalBox();
/*     */ 
/* 328 */     this.chgParmOk = new JButton("OK");
/* 329 */     this.chgParmOk.setFont(this.ssp10);
/* 330 */     this.chgParmOk.setMargin(new Insets(1, 2, 1, 2));
/* 331 */     this.chgParmOk.addActionListener(this);
/*     */ 
/* 333 */     this.chgParmCancel = new JButton("Cancel");
/* 334 */     this.chgParmCancel.setFont(this.ssp10);
/* 335 */     this.chgParmCancel.setMargin(new Insets(1, 2, 1, 2));
/* 336 */     this.chgParmCancel.addActionListener(this);
/*     */ 
/* 338 */     this.defaultParms = new JButton("Default");
/* 339 */     this.defaultParms.setFont(this.ssp10);
/* 340 */     this.defaultParms.setMargin(new Insets(1, 2, 1, 2));
/* 341 */     this.defaultParms.setToolTipText("Reset to default parameters");
/* 342 */     this.defaultParms.addActionListener(this);
/*     */ 
/* 344 */     localBox2.add(Box.createHorizontalGlue());
/* 345 */     localBox2.add(this.chgParmOk);
/* 346 */     localBox2.add(Box.createHorizontalStrut(5));
/* 347 */     localBox2.add(this.chgParmCancel);
/* 348 */     localBox2.add(Box.createHorizontalStrut(5));
/* 349 */     localBox2.add(this.defaultParms);
/* 350 */     localBox2.add(Box.createHorizontalGlue());
/*     */ 
/* 352 */     localBox1.add(getOBVBox(true));
/* 353 */     localBox1.add(localBox2);
/*     */ 
/* 355 */     this.chgParmDialog.getContentPane().add(localBox1);
/* 356 */     this.chgParmDialog.setSize(250, 100);
/* 357 */     this.chgParmDialog.setLocationRelativeTo(this.ep);
/* 358 */     this.chgParmDialog.setVisible(true);
/*     */   }
/*     */ 
/*     */   public boolean validateParm()
/*     */   {
/* 365 */     int i = this.parm1;
/*     */     try
/*     */     {
/* 369 */       i = Integer.parseInt(this.parm1TF.getText().trim());
/*     */     }
/*     */     catch (NumberFormatException localNumberFormatException)
/*     */     {
/* 375 */       JOptionPane.showMessageDialog(null, "Error in OBV parameter.Enter only numbers greater than 2.", null, 0);
/*     */ 
/* 378 */       this.parm1TF.setText("" + this.parm1);
/*     */ 
/* 380 */       return false;
/*     */     }
/*     */ 
/* 384 */     if (i > 200)
/*     */     {
/* 386 */       JOptionPane.showMessageDialog(null, "Error in OBV parameter.Enter values between 2 and 200.", null, 0);
/*     */ 
/* 389 */       this.parm1TF.setText("" + this.parm1);
/*     */ 
/* 391 */       return false;
/*     */     }
/*     */ 
/* 395 */     if (i < 2)
/*     */     {
/* 397 */       JOptionPane.showMessageDialog(null, "Error in OBV parameter.Enter values between 2 and 200.", null, 0);
/*     */ 
/* 400 */       this.parm1TF.setText("" + this.parm1);
/*     */ 
/* 402 */       return false;
/*     */     }
/*     */ 
/* 406 */     this.parm1 = i;
/*     */ 
/* 408 */     return true;
/*     */   }
/*     */ 
/*     */   public void actionPerformed(ActionEvent paramActionEvent)
/*     */   {
/* 415 */     if (paramActionEvent.getSource() == this.chgParmOk)
/*     */     {
/* 417 */       if (!validateParm()) {
/* 418 */         return;
/*     */       }
/* 420 */       redrawChart();
/* 421 */       this.chgParmDialog.dispose();
/*     */     }
/*     */ 
/* 425 */     if (paramActionEvent.getSource() == this.chgParmCancel)
/*     */     {
/* 427 */       this.chgParmDialog.dispose();
/*     */     }
/*     */ 
/* 431 */     if (paramActionEvent.getSource() == this.defaultParms)
/*     */     {
/* 433 */       setDefaultParms();
/*     */     }
/*     */   }
/*     */ 
/*     */   public void setDefaultParms()
/*     */   {
/* 442 */     this.parm1TF.setText("12");
/*     */   }
/*     */ 
/*     */   public void vZoom(boolean paramBoolean)
/*     */   {
/* 449 */     if (paramBoolean)
/* 450 */       this.yScale += 0.2F;
/* 451 */     else if (this.yScale >= 1.2F) {
/* 452 */       this.yScale -= 0.2F;
/*     */     }
/* 454 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   public void hZoom(boolean paramBoolean)
/*     */   {
/* 461 */     if (paramBoolean)
/* 462 */       this.xScale += 0.2F;
/* 463 */     else if (this.xScale >= 1.2F) {
/* 464 */       this.xScale -= 0.2F;
/*     */     }
/* 466 */     if (this.noOfDays == 150)
/* 467 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/* 469 */       this.stickWidth = (1.5D * this.xScale);
/* 470 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   public void resetZoom()
/*     */   {
/* 477 */     this.yScale = 1.0F;
/* 478 */     this.xScale = 1.0F;
/* 479 */     if (this.noOfDays == 150)
/* 480 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/* 482 */       this.stickWidth = (1.5D * this.xScale);
/* 483 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   protected void clear(Graphics paramGraphics)
/*     */   {
/* 490 */     super.paintComponent(paramGraphics);
/*     */   }
/*     */ 
/*     */   protected void paintComponent(Graphics paramGraphics)
/*     */   {
/* 497 */     clear(paramGraphics);
/* 498 */     Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
/* 499 */     drawChart(localGraphics2D);
/* 500 */     drawValues(localGraphics2D);
/*     */   }
/*     */ 
/*     */   private void drawChart(Graphics2D paramGraphics2D)
/*     */   {
/* 529 */     this.refY = 10.0D;
/* 530 */     this.refX = 50.0D;
/* 531 */     setFont(this.ssp10);
/* 532 */     String str = "On Balance Volume";
/* 533 */     paramGraphics2D.setPaint(new Color(100, 240, 250));
/* 534 */     paramGraphics2D.drawString(str, 50, 10);
/*     */ 
/* 536 */     str = "OBV";
/* 537 */     paramGraphics2D.setPaint(new Color(80, 150, 125));
/* 538 */     paramGraphics2D.drawString(str, 155, 10);
/*     */ 
/* 540 */     str = "OBV MA[" + this.parm1 + "]";
/* 541 */     paramGraphics2D.setPaint(new Color(210, 210, 20));
/* 542 */     paramGraphics2D.drawString(str, 185, 10);
/*     */ 
/* 545 */     this.refL1.setLine(50.0D, 10.0D, 50.0D, this.yScale * 100.0F + 10.0F);
/* 546 */     this.refL2.setLine(750.0F * this.xScale + 50.0F, 10.0D, 750.0F * this.xScale + 50.0F, this.yScale * 100.0F + 10.0F);
/* 547 */     paramGraphics2D.setPaint(Color.white);
/* 548 */     paramGraphics2D.draw(this.refL1);
/* 549 */     paramGraphics2D.draw(this.refL2);
/*     */ 
/* 551 */     for (int i = 0; i < 14; i++)
/*     */     {
/* 553 */       this.refX += 50.0F * this.xScale;
/* 554 */       this.gridY.setLine(this.refX, 10.0D, this.refX, this.yScale * 100.0F + 10.0F);
/* 555 */       paramGraphics2D.setPaint(Color.darkGray);
/* 556 */       paramGraphics2D.draw(this.gridY);
/*     */     }
int i;
/*     */ 
/* 560 */     for (i = 0; i < 11; i++)
/*     */     {
/* 562 */       this.yrefL1.setLine(50.0D, this.refY, 40.0D, this.refY);
/*     */ 
/* 564 */       if (this.maxVal > 99999.0F)
/* 565 */         str = this.df.format(this.maxVal - (this.maxVal - this.minVal) / 10.0F * i);
/*     */       else {
/* 567 */         str = "" + (int)(this.maxVal - (this.maxVal - this.minVal) / 10.0F * i);
/*     */       }
/* 569 */       paramGraphics2D.setPaint(Color.lightGray);
/* 570 */       paramGraphics2D.drawString(str, 5, (int)this.refY);
/* 571 */       this.yrefL2.setLine(750.0F * this.xScale + 50.0F, this.refY, 750.0F * this.xScale + 60.0F, this.refY);
/*     */ 
/* 573 */       paramGraphics2D.drawString(str, (int)(750.0F * this.xScale + 53.0F), (int)this.refY);
/* 574 */       this.gridX.setLine(50.0D, this.refY, 750.0F * this.xScale + 50.0F, this.refY);
/* 575 */       paramGraphics2D.setPaint(Color.white);
/* 576 */       paramGraphics2D.draw(this.yrefL1);
/* 577 */       paramGraphics2D.draw(this.yrefL2);
/* 578 */       paramGraphics2D.setPaint(Color.darkGray);
/* 579 */       paramGraphics2D.draw(this.gridX);
/* 580 */       this.refY += 10.0F * this.yScale;
/*     */     }
/*     */ 
/* 584 */     this.yfactor = (this.yScale * 100.0F / (this.maxVal - this.minVal));
/* 585 */     this.startPointX = (750.0F * this.xScale + 50.0F - (this.stickWidth + 1.0F * this.xScale));
/* 586 */     this.dateRef = (this.sq.count - 1);
/* 587 */     this.daysRef = 1;
/*     */ 
/* 590 */     for (i = this.sq.count - 1; i > 1; i--)
/*     */     {
/* 592 */       if (this.daysRef == this.noOfDays)
/*     */         break;
/* 594 */       paramGraphics2D.setFont(this.ssp10);
/*     */ 
/* 597 */       if (i > this.parm1)
/*     */       {
/* 599 */         this.p1Y = (this.yScale * 100.0F + 10.0F - (this.obvMA_parm1[i] - this.minVal) * this.yfactor);
/* 600 */         this.p2Y = (this.yScale * 100.0F + 10.0F - (this.obvMA_parm1[(i - 1)] - this.minVal) * this.yfactor);
/*     */ 
/* 602 */         this.l1.setLine(this.startPointX, this.p1Y, this.startPointX - this.stickWidth - 1.0F * this.xScale, this.p2Y);
/* 603 */         paramGraphics2D.setPaint(new Color(210, 210, 20));
/* 604 */         paramGraphics2D.draw(this.l1);
/*     */       }
/*     */ 
/* 608 */       if (i > 1)
/*     */       {
/* 610 */         this.p11Y = (this.yScale * 100.0F + 10.0F - (this.obv[i] - this.minVal) * this.yfactor);
/* 611 */         this.p22Y = (this.yScale * 100.0F + 10.0F - (this.obv[(i - 1)] - this.minVal) * this.yfactor);
/*     */ 
/* 613 */         this.l2.setLine(this.startPointX, this.p11Y, this.startPointX - this.stickWidth - 1.0F * this.xScale, this.p22Y);
/* 614 */         paramGraphics2D.setPaint(new Color(80, 150, 125));
/* 615 */         paramGraphics2D.draw(this.l2);
/*     */       }
/*     */ 
/* 619 */       if ((i > this.parm1) && (this.obv[i] - this.obvMA_parm1[i] >= 0.0F) && (this.obv[(i - 1)] - this.obvMA_parm1[(i - 1)] < 0.0F))
/*     */       {
/* 621 */         this.x1 = this.startPointX;
/* 622 */         this.x2 = (this.startPointX - this.stickWidth - 1.0F * this.xScale);
/* 623 */         this.y1 = this.p1Y;
/* 624 */         this.y2 = this.p2Y;
/* 625 */         this.u1 = this.x1;
/* 626 */         this.u2 = this.x2;
/* 627 */         this.v1 = this.p11Y;
/* 628 */         this.v2 = this.p22Y;
/*     */ 
/* 630 */         this.b1 = ((this.y1 - this.y2) / (this.x1 - this.x2));
/* 631 */         this.a1 = (this.y1 - this.b1 * this.x1);
/*     */ 
/* 633 */         this.b2 = ((this.v1 - this.v2) / (this.u1 - this.u2));
/* 634 */         this.a2 = (this.v1 - this.b2 * this.u1);
/*     */ 
/* 636 */         this.xi = (-1.0D * (this.a1 - this.a2) / (this.b1 - this.b2));
/* 637 */         this.yi = (this.a1 + this.b1 * this.xi);
/*     */ 
/* 639 */         paramGraphics2D.setPaint(Color.green);
/* 640 */         this.uA.setLine(this.xi, this.yi - 5.0D, this.xi, this.yi + 5.0D);
/* 641 */         this.lA.setLine(this.xi, this.yi - 5.0D, this.xi - 3.0D, this.yi);
/* 642 */         this.hA.setLine(this.xi, this.yi - 5.0D, this.xi + 3.0D, this.yi);
/* 643 */         paramGraphics2D.draw(this.uA);
/* 644 */         paramGraphics2D.draw(this.lA);
/* 645 */         paramGraphics2D.draw(this.hA);
/*     */       }
/*     */ 
/* 649 */       if ((i > this.parm1) && (this.obv[i] - this.obvMA_parm1[i] < 0.0F) && (this.obv[(i - 1)] - this.obvMA_parm1[(i - 1)] > 0.0F))
/*     */       {
/* 651 */         this.x1 = this.startPointX;
/* 652 */         this.x2 = (this.startPointX - this.stickWidth - 1.0F * this.xScale);
/* 653 */         this.y1 = this.p1Y;
/* 654 */         this.y2 = this.p2Y;
/* 655 */         this.u1 = this.x1;
/* 656 */         this.u2 = this.x2;
/* 657 */         this.v1 = this.p11Y;
/* 658 */         this.v2 = this.p22Y;
/*     */ 
/* 660 */         this.b1 = ((this.y1 - this.y2) / (this.x1 - this.x2));
/* 661 */         this.a1 = (this.y1 - this.b1 * this.x1);
/*     */ 
/* 663 */         this.b2 = ((this.v1 - this.v2) / (this.u1 - this.u2));
/* 664 */         this.a2 = (this.v1 - this.b2 * this.u1);
/*     */ 
/* 666 */         this.xi = (-1.0D * (this.a1 - this.a2) / (this.b1 - this.b2));
/* 667 */         this.yi = (this.a1 + this.b1 * this.xi);
/*     */ 
/* 669 */         paramGraphics2D.setPaint(Color.red);
/* 670 */         this.uA.setLine(this.xi, this.yi - 5.0D, this.xi, this.yi + 5.0D);
/* 671 */         this.lA.setLine(this.xi, this.yi + 5.0D, this.xi - 3.0D, this.yi);
/* 672 */         this.hA.setLine(this.xi, this.yi + 5.0D, this.xi + 3.0D, this.yi);
/* 673 */         paramGraphics2D.draw(this.uA);
/* 674 */         paramGraphics2D.draw(this.lA);
/* 675 */         paramGraphics2D.draw(this.hA);
/*     */       }
/*     */ 
/* 679 */       if (this.dateRef == i)
/*     */       {
/* 681 */         paramGraphics2D.setFont(this.ssp9);
/* 682 */         str = ((String)this.sq.date.get(i)).substring(0, 6);
/* 683 */         if (this.obv[i] >= this.obvMA_parm1[i])
/* 684 */           paramGraphics2D.setPaint(Color.green);
/*     */         else {
/* 686 */           paramGraphics2D.setPaint(Color.red);
/*     */         }
/* 688 */         paramGraphics2D.drawString(str, (int)this.startPointX, (int)(this.yScale * 100.0F + 20.0F));
/* 689 */         if (this.noOfDays == 150)
/* 690 */           this.dateRef -= 10;
/*     */         else
/* 692 */           this.dateRef -= 20;
/* 693 */         paramGraphics2D.setFont(this.ssp10);
/*     */       }
/*     */ 
/* 697 */       this.startPointX = (this.startPointX - this.stickWidth - 1.0F * this.xScale);
/* 698 */       this.daysRef += 1;
/*     */     }
/*     */   }
/*     */ 
/*     */   public static void main(String[] paramArrayOfString)
/*     */   {
/* 761 */     FileDownloader localFileDownloader = new FileDownloader();
/* 762 */     localFileDownloader.downloadFiles();
/* 763 */     SymQuotes localSymQuotes = new SymQuotes("WIPRO", localFileDownloader.datesToRead, 1, 1, "ns");
/*     */ 
/* 765 */     OBVChart localOBVChart = new OBVChart(localSymQuotes, 12);
/*     */ 
/* 767 */     JFrame localJFrame = new JFrame("Test");
/* 768 */     localJFrame.setDefaultCloseOperation(3);
/* 769 */     localJFrame.getContentPane().add(localOBVChart);
/* 770 */     localJFrame.pack();
/* 771 */     localJFrame.setSize(850, 175);
/* 772 */     localJFrame.setVisible(true);
/*     */   }
/*     */ 
/*     */   public class EastPanel extends JPanel
/*     */   {
/*     */     private JLabel title;
/*     */     private JLabel obvL;
/*     */     private JLabel obvMaL;
/*     */     private JLabel trendL;
/*     */     private ChartHelpButton chb;
/* 710 */     private Font valuesF = new Font("Sanserif", 0, 11);
/* 711 */     public Box buttonsPanel = Box.createHorizontalBox();
/*     */ 
/*     */     public EastPanel()
/*     */     {
/* 715 */       this.title = new JLabel("OBV");
/* 716 */       this.obvL = new JLabel("OBV: " + OBVChart.this.df.format(OBVChart.this.obv[(OBVChart.this.sq.count - 1)]));
/* 717 */       this.obvMaL = new JLabel("OBV MA[" + OBVChart.this.parm1 + "]: " + OBVChart.this.df.format(OBVChart.this.obvMA_parm1[(OBVChart.this.sq.count - 1)]));
/*     */ 
/* 719 */       this.trendL = new JLabel("Trend: " + OBVChart.this.trend);
/* 720 */       this.chb = new ChartHelpButton("http://www.profitindicators.com/home/indicators/obv.htm", "Help on OBV");
/*     */ 
/* 722 */       this.chb.setFont(this.valuesF);
/*     */ 
/* 724 */       this.obvL.setFont(this.valuesF);
/* 725 */       this.obvMaL.setFont(this.valuesF);
/* 726 */       this.trendL.setFont(this.valuesF);
/*     */ 
/* 728 */       this.buttonsPanel.add(this.chb);
/* 729 */       this.buttonsPanel.add(Box.createHorizontalStrut(2));
/* 730 */       this.buttonsPanel.setAlignmentX(0.0F);
/*     */ 
/* 732 */       setLayout(new BoxLayout(this, 3));
/*     */ 
/* 734 */       add(this.title);
/* 735 */       add(this.obvL);
/* 736 */       add(this.obvMaL);
/* 737 */       add(new JLabel(" "));
/* 738 */       add(this.trendL);
/* 739 */       add(this.buttonsPanel);
/* 740 */       add(Box.createVerticalGlue());
/*     */ 
/* 742 */       setBackground(new Color(243, 245, 252));
/*     */     }
/*     */ 
/*     */     public void updateValues()
/*     */     {
/* 749 */       this.obvL.setText("OBV: " + OBVChart.this.df.format(OBVChart.this.obv[(OBVChart.this.sq.count - 1)]));
/* 750 */       this.obvMaL.setText("OBV MA[" + OBVChart.this.parm1 + "]: " + OBVChart.this.df.format(OBVChart.this.obvMA_parm1[(OBVChart.this.sq.count - 1)]));
/* 751 */       this.trendL.setText("Trend: " + OBVChart.this.trend);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Deebak\Downloads\profitindicatorsv2-05.jar
 * Qualified Name:     OBVChart
 * JD-Core Version:    0.6.0
 */